package io.binghe.concurrent.lab06;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * 创建一个定长的线程池，支持定时、周期性的任务执行
 * @author CurleyG
 * @date 2025/3/25 23:51
 */

public class ScheduledThreadPoolExample {
    public static void main(String[] args) {
        ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2);

        Runnable task = () -> System.out.println("任务执行时间：" + System.currentTimeMillis());

        // 延迟 3 秒执行
        scheduler.schedule(task, 3, TimeUnit.SECONDS);

        scheduler.shutdown();
    }
}
